package com.news.service;

import java.util.ArrayList;
import java.util.List;

import com.news.dao.UserPageDao;
import com.news.entity.Page;
import com.news.entity.User;

public class UserPageService {
	/**
	 * 获取页码信息
	 * @return 页码列表
	 */
	public List<Page> getPages(){
		UserPageDao userDao=new UserPageDao();
		int total= userDao.getTotal();
		int pageSize=userDao.pageSize;
		//计算出总页码
		int pageCount=total%pageSize==0?total/pageSize:total/pageSize+1;
		List<Page> pages=new ArrayList<Page>();
		for(int i=1;i<=pageCount;i++){
			Page page=new Page();
			page.setNumber(i);
			page.setText("第"+i+"页");
			pages.add(page);
		}
		return pages;
	}
	
	/**
	 * 查询当前页品牌数据
	 * @param current 当前页码
	 * @return 页码集合
	 */
	public List<User> getUsersByCurrentPage(int current){
		UserPageDao userpageDao=new UserPageDao();
		return userpageDao.getUsersByCurrentPage(current);
	}

}
